package com.atguigu.yygh.hosp.controller.user;

import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.result.R;
import com.atguigu.yygh.vo.hosp.ScheduleOrderVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/*==========================================
      时 间:   2022-04-26
      讲 师:   刘  辉
      描 述:   尚硅谷教学团队
 ==========================================*/
@RestController
@RequestMapping("/user/hosp")
public class UserScheduleController {


    @Autowired
    private ScheduleService scheduleService;


    @GetMapping("/{page}/{limit}/{hoscode}/{depcode}")
    public R getSchedulePageByCondition(@PathVariable Integer page,
                                        @PathVariable Integer limit,
                                        @PathVariable String hoscode,
                                        @PathVariable String depcode) {
        Map<String, Object> map = scheduleService.getSchedulePageByCondition(page, limit, hoscode, depcode);
        return R.ok().data(map);
    }

    @ApiOperation(value = "获取排班数据")
    @GetMapping("findScheduleList/{hoscode}/{depcode}/{workDate}")
    public R findScheduleList(
            @PathVariable String hoscode,
            @PathVariable String depcode,
            @PathVariable String workDate) {
        List<Schedule> scheduleList = scheduleService.getScheduleDetail(hoscode, depcode, workDate);
        return R.ok().data("scheduleList", scheduleList);
    }



    //根据排班id排班信息
    @GetMapping("schedule/{scheduleId}")
    public R getScheduleById(@PathVariable String  scheduleId){
        Schedule schedule= scheduleService.getScheduleById(scheduleId);
        return R.ok().data("schedule",schedule);
    }

    //根据排班id排班信息：:用于远程调用
    @GetMapping("scheduleOrderVo/{scheduleId}")
    public ScheduleOrderVo getScheduleOrderVoById(@PathVariable("scheduleId") String  scheduleId){
        return  scheduleService.getScheduleOrderVoById(scheduleId);
    }


}
